package main

import (
    "fmt"
    "math/rand"
    "net/http"
    "time"
)

var servers = []string{
    "http://192.168.1.100:8080",
    "http://192.168.1.101:8080",
    // 可根据需要添加更多服务器
}

func getServer() string {
    rand.Seed(time.Now().UnixNano())
    return servers[rand.Intn(len(servers))]
}

func Balancer() {
    server := getServer()
    resp, err := http.Get(server)
    if err != nil {
        fmt.Printf("请求失败: %v\n", err)
        return
    }
    defer resp.Body.Close()
    fmt.Printf("成功请求到 %s\n", server)
}